<?php
require_once 'base.php';

$sql = "SELECT id, type, content, source, add_time, status FROM epigram WHERE status>-1 ORDER BY id DESC LIMIT 1";

$resource = @mysql_query($sql);

if ($rs = mysql_fetch_array($resource, MYSQL_ASSOC)){
	$message = array('type' => $typeArr[$rs['type']], 'content' => $rs['content']);

	// 修改条目状态
	if ($rs['status'] > -1){
		$sqlUpdate = 'UPDATE epigram SET status=-1 WHERE id=' . $rs['id'];
		@mysql_query($sqlUpdate);
	}
}else{
	$message = array('msg' => 'No data!');
}

mysql_close($conn);

echo json_encode($message);
?>